package demo9;

import java.util.ArrayList;
import java.util.Random;

/*
生成6个1-33之间的随机整数，添加到集合，并且遍历输出
 */
public class ArrayListTest1 {
    public static void main(String[] args) {
        ArrayList<Integer> list = new ArrayList<>();
        Random ran = new Random();


        for (int i = 0; i < 6; i++) {
            int num = ran.nextInt(100)+1;
            list.add(num);
            System.out.println("生成的6个随机数是"+num);
        }
        System.out.println("============================");
        for (int i = 0; i < list.size(); i++) {
            System.out.println("遍历生成的6个随机数是:"+ list.get(i));
        }

    }
}
